<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>授权页面</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <div class="welcome-container">
        <h2>欢迎，{{username}}<span id="username-display"></span>!</h2>
        <button id="logout-btn" class="btn">注销</button>
    </div>
    <script>
        document.getElementById('logout-btn').addEventListener('click', function (event) {
            event.preventDefault();

            fetch('/logout')
                .then(response => response.json())
                .then(data => {
                    if (data.success) {
                        window.location.href = '/'; // 登录成功后跳转到主页
                    }
                })
                .catch(error => {
                    console.error('Error:', error);
                });
        });

    </script>
</body>

</html>